package jpa;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LoginUserHandler implements IRequestHandler {

	@Override
	public void handleRequest(HttpServletRequest request,
			HttpServletResponse response, IStatelessBean stateless,
			IStatefulBean stateful, ServletContext sc) throws ServletException, IOException 
	{
		
		RequestDispatcher rd = request.getRequestDispatcher("login.jsp");
				
		String user = request.getParameter("username"); //gets name
		String password = request.getParameter("password"); //gets password
		
		
		if(!user.equals(null) || !password.equals(null))
		{
			stateful.login(user, password); //Calls this fine.			
		}
	
        rd.forward(request, response);
	}

}
